import { defineStore } from 'pinia';

export const useCounterStore = defineStore('counter', {
    state: () => ({
        menuList: [
            {
                id: 1,
                authName: '首页',
                icon: 'HomeFilled',
                path: { name: 'user-home' }
            },
        ],
        rowData: {
            img: ''
        },
    }),
    actions: {
        selectMenu(val){
            //判断添加的数组是否为首页
            if(val.authName!=='首页'){
                const index = this.menuList.findIndex(item=> item.authName === val.authName)
                //如果不存在
                if(index === -1){
                    this.menuList.push(val)
                }
            }
        },
        //删除指定的tag数据
        closeTag(item){
            const index =this.menuList.findIndex(val=> val.authName === item.authName)
            this.menuList.splice(index,1)
        },
    },
});
export default useCounterStore;
